package com.zbj.consul.provider;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * FooBarController
 *
 * @author weigang
 * @create 2019-08-10
 **/
@RestController
// Spring Cloud Comsul Config默认就支持动态刷新，只需要在需要动态刷新的类上加上@RefreshScope注解即可
@RefreshScope
public class FooBarController {

    @Value("${foo.bar}")
    String fooBar;

    @Autowired
    private Foo foo;

    @GetMapping("/foo")
    public String foo() {
        return fooBar;
    }

    @GetMapping("/foo1")
    public String foo1() {
        return foo.getBar();
    }

    public String getFooBar() {
        return fooBar;
    }

    public void setFooBar(String fooBar) {
        this.fooBar = fooBar;
    }
}